Ext.define('Xyh.controller.Feetype', {
			extend : 'Ext.app.Controller',
			models : ['Feetype'],
			stores : ['Feetype'],
			views : ['feetype.List','feetype.Add','feetype.Edit'],

			init : function() {
				this.control({
							'feetype button[action=addFeetype]' : {
								click : this.showAddFeetype
							},
							'feetypeadd button[action=save]' : {
								click : this.addFeetype
							},
							'feetype gridpanel' : {
								itemdblclick : this.showUpdateWindow
							},
							'feetypeedit button[action=save]' : {
								click : this.updateFeetype
							}
						});

			},
			showAddFeetype : function(button) {
				Ext.widget('feetypeadd');
			},
			addFeetype : function(button) {
				var win = button.up('window');
				var form = win.down('form').getForm();
				if (form.isValid()) {
					form.submit({
								success : function(form, action) {
									Ext.Msg.alert('OK', '添加成功');
									win.close();
									Ext.getStore('Feetype').load();

								},
								failure : function(form, action) {
									Ext.Msg.alert('ERROR', '添加失败');
								}
							});
				}
			},
			showUpdateWindow : function(grid, record) {
				var edit = Ext.createWidget('feetypeedit');
				edit.down('form').loadRecord(record);

			},
			updateFeetype : function(button) {
				var win = button.up('window');
				var form = win.down('form').getForm();
				if (form.isValid()) {
					form.submit({
								success : function(form, action) {
									Ext.Msg.alert('OK', '修改成功');
									win.close();
									Ext.getStore('Feetype').load();
								},
								failure : function(form, action) {
									Ext.Msg.alert('ERROR', '修改失败');
								}
							});
				}
			}

		});